<template>
    <div>
        <div class="form-section">
            <div class="form-item  form-item-style1">
                <div class="label-title">
                    <label>姓名</label>
                </div>
                <div>
                    <p>{{detailData.PersonName}}</p>
                </div>
            </div>
            <div class="form-item form-item-style1">
                <div class="label-title">
                    <label>性别</label>
                </div>
                <div>
                    <p>{{detailData.Sex}}</p>
                </div>
            </div>
            <div class="form-item form-item-style1">
                <div class="label-title">
                    <label>工种</label>
                </div>
                <div>
                    <p>{{detailData.Category}}</p>
                </div>
            </div>
            <div class="form-item form-item-style1">
                <div class="label-title">
                    <label>联系电话</label>
                </div>
                <div>
                    <p>{{detailData.TelPhone}}</p>
                </div>
            </div>
            <div class="form-item form-item-style1">
                <div class="label-title">
                    <label>发证单位</label>
                </div>
                <div>
                    <p>{{detailData.CertDept}}</p>
                </div>
            </div>
            <div class="form-item form-item-style1">
                <div class="label-title">
                    <label>证书编号</label>
                </div>
                <div>
                    <p>{{detailData.CertNo}}</p>
                </div>
            </div>
            <div class="form-item form-item-style1">
                <div class="label-title">
                    <label>证书有效期</label>
                </div>
                <div>
                    <p>{{detailData.CertExpDate}}</p>
                </div>
            </div>
        </div>
        <div class="cut-off-rule"></div>
        <div class="form-section">
            <h3>附件信息</h3>
            <div class="form-item form-item-style1"
                 @click="preview"
                 v-if="detailData.FileName">
                <div class="label-title label-title1">
                    <label>{{detailData.FileName}}</label>
                </div>
                <div class="right-section">
                    <span>预览</span>
                    <x-icon type="ios-arrow-right"
                            size="20"
                            class="icon-right"
                            fill="#999"></x-icon>
                </div>
            </div>
        </div>
        <myMenu></myMenu>
    </div>
</template>
<script>
import myMenu from '@/commonComponents/menu'
export default {
    name: 'electricianUsersDetail',
    data () {
        return {
            regImg: /\.(png|jpg|PNG|JPG|jpeg|JPEG|gif|GIF)$/,
            userInfo: {},
            detailData: {}
        }
    },
    components: {
        myMenu
    },
    created () {
        this.userInfo = JSON.parse(localStorage.getItem('userInfo')) || {}
        this.getDetail()
    },
    methods: {
        preview () {
            if (this.regImg.test(this.detailData.FileName)) {
                this.$router.push({
                    path: '/previewImg',
                    query: {
                        previewImg: this.detailData.certFile
                    }
                })
            } else {
                wx.miniProgram.navigateTo({
                    url: `/pages/openDocument/index?filePath=${this.detailData.certFile}`
                })
            }
        },
        getDetail () {
            let params = {
                'allowPaging': true,
                'business': 'GetElectricianRosterData_XX',
                'data': {
                    'id': this.$route.query.id
                },
                'pageIndex': 0,
                'pageSize': 0,
                'tokenId': '',
                'userId': this.userInfo.userid // -- - 用户ID
            }
            this.$axiosAjax.getConfigJson(params).then(res => {
                if (res.data.code === 0) {
                    this.detailData = res.data.data
                }
            }).finally(() => {
                this.$vux.loading.hide()
            })
        }
    }
}
</script>
<style scoped>
.sectionML20 {
    margin-left: 20px;
}
</style>
